﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.UI.WebControls;
using Xuanren_FrontEnd.Model;

namespace Xuanren_FrontEnd.Controllers
{
    public class ArticleController : Controller
    {
        private XuanrenTherapyEntities db = new XuanrenTherapyEntities();
        [HttpGet]
        public ActionResult ArticleList(int id)
        {
            //根据分类查询新闻
            ViewBag.NewsList = db.News.Where(x => x.typeId == id && x.isShowHome == "1").
                                       Take(10).OrderByDescending(p => p.create_time);
            //新闻分类列表
            ViewBag.ArticleTyleList = db.NewsType.Where(x => true);

            ViewBag.ArticleTyle = id;
            return View();
        }
         /// <summary>
         /// 根据ID查询新闻
         /// </summary>
         /// <param name="id">新闻ID</param>
         /// <returns></returns>
        public ActionResult ArticleDetail(int id) {
            News news= db.News.SingleOrDefault(x=>x.id==id);

            ViewBag.ArticleTyleList = db.NewsType.Where(x => true);

            ViewBag.ArticleId = id;

            return View(news);
        }
    }
}